package sg.edu.nus.iss.vmcs.util;

import java.awt.Color;
import java.awt.Panel;
import java.awt.event.ActionListener;

public class DisplayPanel extends Panel{

	private static final Color DEFAULT_FG = Color.yellow;
	private static final Color DEFAULT_BG = Color.red;
	private static final Color DEFAULT_OFF = Color.white;

	private Color onFg = DEFAULT_FG, onBg = DEFAULT_BG;
	private Color offFg = DEFAULT_OFF, offBg = Color.black;
	/**
	 * Method to enable or disable the display panel
	 * @param status
	 */
	public void setActive(boolean status){
		setEnabled(status);
	}
	/**
	 * Add the action listener to the panel
	 * @param actionListener
	 */
	public void addListener(ActionListener actionListener){
		addListener(actionListener);
	}
	/**
	 * 
	 * Set the text value of the display panel.
	 * @param value
	 */
	public void setValue(String value){
		setValue(value);
	}
	
	/**
	 * 
	 * Set the text value of the display panel.
	 * @param value
	 */
	public void setValue(int value){
		setValue(value);
	}
	
	/**
	 * Set the state of the display panel
	 * @param state
	 */
	public void setState(boolean state){
		if(state){
			setBackground(onFg);
			setForeground(onBg);
		}else{
			setBackground(offFg);
			setForeground(offBg);
		}

	}
	/**
	 * Return the object value in string
	 * @return
	 */
	public String getValue(){
		return getValue().toString();
	}
	/**
	 * Clear this display panel
	 */
	public void clear() {
		clear();
	}

}
